package cn.com.yusys.yusp.custManager.web.rest;

import cn.com.yusys.yusp.commons.mapper.QueryModel;
import cn.com.yusys.yusp.commons.web.rest.dto.ResultDto;
import cn.com.yusys.yusp.custManager.service.MarketTaskManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author zoie
 */
@RestController
@RequestMapping("/api/marketTaskManager")
public class MarketTaskManagerResource {

    @Autowired
    MarketTaskManagerService marketManagerService;

    /**
     * 查询营销任务
     * @param queryModel
     * @return
     */
    @GetMapping("/taskQuery")
    public ResultDto<List<Map<String, Object>>> taskQuery(QueryModel queryModel) {
        List<Map<String, Object>> list = marketManagerService.taskQuery(queryModel);
        return new ResultDto<>(list);
    }

    /**
     * 获取当下客户群组
     * @param queryModel
     * @return
     */
    @GetMapping("/getTaskGroups")
    public ResultDto<List<Map<String, Object>>> getTaskGroups(QueryModel queryModel) {
        List<Map<String, Object>> list = marketManagerService.getTaskGroups(queryModel);
        return new ResultDto<>(list);
    }

    /**
     * 新增营销任务
     * @param map
     * @return
     */
    @PostMapping("/insertData")
    public ResultDto<Integer> insertData(@RequestBody Map map) {
        System.out.println("map:"+map);
        Integer result = marketManagerService.insertData(map);
        return new ResultDto<>(result);
    }

    /**
     * 修改营销任务
     * @param map
     * @return
     */
    @PostMapping("/editData")
    public ResultDto<Integer> editData(@RequestBody Map map) {
        Integer result = marketManagerService.updateData(map);
        return new ResultDto<>(result);
    }

    /**
     * 删除营销任务
     * @param taskNums
     * @return
     */
    @GetMapping("/deleteTask/{taskNums}")
    public ResultDto<Integer> deletetask(@PathVariable String taskNums) {
        Integer result = marketManagerService.delete(taskNums);
        return new ResultDto<>(result);
    }

    /**
     * 下达营销任务
     * @param map
     * @return
     */
    @PostMapping("/giveTask")
    public ResultDto<Integer> givetask(@RequestBody Map map) {
        Integer result = marketManagerService.givetask(map);
        return new ResultDto<>(result);
    }

    /**
     * 获取下发网格
     * @param queryModel
     * @return
     */
    @GetMapping("/getLevelGrid")
    public ResultDto<List<Map<String, Object>>> getLevelGrid(QueryModel queryModel) {
        List<Map<String, Object>> list = marketManagerService.getLevelGrid(queryModel);
        return new ResultDto<>(list);
    }

    /**
     * 指标完成情况
     * @param queryModel
     * @return
     */
    @GetMapping("/targetTask")
    public ResultDto<List<Map<String, Object>>> targetTask(QueryModel queryModel) {
        List<Map<String, Object>> list = marketManagerService.targetTask(queryModel);
        return new ResultDto<>(list);
    }

}
